    @extends('common.admin-master')

    @section('html-body')
    <div class="content">
        
        <div class="header">
            <h3 class="page-title">编辑投资人</h3>
        </div>

        <div class="container-fluid">
            <form method="post" action="{{route('Api.Admin.editInvestorByAdmin' , ['id'=>$investor->id])}}" >
                <input type="hidden" name="_token" value="{{ csrf_token() }}"/>

                <div class="well">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#home" data-toggle="tab">投资人信息</a></li>
                        <li><a href="#profile" data-toggle="tab">投资信息</a></li>
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane active in" id="home">
                            <em class="pro-name"></em><a class="logo" href="javascript:void(0);"
                                                         id="inputImage"><img
                                        id="user_logo_url" src="{{route('Api.Images.Show')}}"
                                        title="点击上传logo" width="100" height="100" /></a><input
                                    type="hidden" id="photo_id" value="" /><em class="msg"></em>
                            <label>姓名</label>
                            <input type="text" name="realname" value="@if($investor->userInfo){{$investor->userInfo->realname}}@endif"
                                   class="input-xlarge">

                            <label>所在地</label>
                            <input type="text" name="province" value="@if($investor->userInfo){{$investor->userInfo->province}}@endif" class="input-xlarge">
                            <input type="text" name="city" value="@if($investor->userInfo){{$investor->userInfo->city}}@endif" class="input-xlarge">

                            <label>微信</label>
                            <input type="text" name="wechat" value="@if($investor->userInfo){{$investor->userInfo->wechat}}@endif" class="input-xlarge">
                            <label>微博</label>
                            <input type="text" name="weibo"  value="@if($investor->userInfo){{$investor->userInfo->weibo}}@endif" class="input-xlarge">
                            <label>脉脉</label>
                            <input type="text" name="maimai" value="@if($investor->userInfo){{$investor->userInfo->maimai}}@endif" class="input-xlarge">
                            <label>毕业院校</label>
                            <input type="text" name="edu_school" value="@if($investor->userInfo){{$investor->userInfo->edu_school}}@endif" class="input-xlarge">
                            <label>职位</label>
                            <input type="text" name="position" value="@if($investor->userInfo){{$investor->userInfo->position}}@endif" class="input-xlarge">
                            <label>个人简介</label>
                            <textarea name="user_desc" rows="5" class="input-xlarge">@if($investor->userInfo){{$investor->userInfo->user_desc}}@endif</textarea>
                            <input type="hidden" name="user_id" value="{{$investor->id}}">
                        </div>

                        <div class="tab-pane fade" id="profile">
                            <label>所属投资机构</label>
                            <select>
                                <option value="0">请选择投资机构</option>
                                @if($orgs=\App\InvestOrg::all())
                                    @foreach($orgs as $org)
                                        <option value="{{$org->id}}">{{$org->invest_name}}</option>
                                    @endforeach
                                @endif
                            </select>
                            <label>投资领域</label>
                            @if($fields = \App\Fields::get())
                                @foreach($fields as $field)
                                    <input type="checkbox" class="field" name="fields[]"
                                           @if($tmp = $investor->isCheckedFields($investor->id))
                                               @if(in_array($field->id ,$tmp))
                                                   checked="checked"
                                               @endif
                                           @endif
                                           value="{{$field->id}}">{{$field->field}} &nbsp;
                                @endforeach
                            @endif
                            <label>投资阶段</label>
                            @if($phases = \App\Phases::get())
                                @foreach($phases as $phase)
                                    <input type="checkbox" class="phase" name="phases[]"
                                    @if($tmp = $investor->isCheckedPhases($investor->id))
                                        @if(in_array($phase->id ,$tmp))
                                           checked="checked"
                                        @endif
                                    @endif
                                           value="{{$phase->id}}">
                                    {{$phase->phase}} &nbsp;
                                @endforeach
                            @endif
                            <br>
                            <label>投资最小金额</label>
                            <input type="text" class="input-xlarge" name="invest_num_small" value="{{$investor->investor['invest_num_small']}}"/>
                            <label>投资最大金额</label>
                            <input type="text" class="input-xlarge" name="invest_num_big" value="{{$investor->investor['invest_num_big']}}"/>
                        </div>
                    </div>
                </div>

            <div class="btn-toolbar">
                <button type="submit" class="btn btn-primary"><i class="icon-save"></i>
                    保存</button>
                <a href="#myModal" data-toggle="modal" class="btn">取消</a>
                <div class="btn-group">
                </div>
            </div>
            </form>

</div>
</div>

    <script>
        var editUserInfoByAdmin  = "{{route('Api.Admin.editUserInfoByAdmin',['id'=>$investor->id])}}";
        var delUserInfoByAdmin   = "{{route('Api.Admin.delUserInfoByAdmin')}}";
        var editCreaterPage      = "{{route('Admin.Users.editCreaterPage' ,['id'=>$investor->id])}}";
        var delInvestorField     = "{{route('Api.Admin.Users.delInvestorField')}}";
        var delInvestorPhase     = "{{route('Api.Admin.Users.delInvestorPhase')}}";
        var Home                 = "{{route('Admin')}}";
    </script>
    <script src="{{url('/js/admin/investor.js')}}"></script>

    <script type="text/javascript">
        $("[rel=tooltip]").tooltip();

        $('.demo-cancel-click').click(function(){return false;});

        /** tab 选项卡 */
        $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {

            var activeTab = $(e.target).text();

            var previousTab = $(e.relatedTarget).text();
            $(".active-tab span").html(activeTab);
            $(".previous-tab span").html(previousTab);
        });

        /** 头像上传 */
        var uploader = new plupload.Uploader({
            runtimes: 'html5,flash,silverlight,html4',
            browse_button: 'inputImage',
            url: '{{ url('api/upload/image')  }}',

            chunk_size: '2mb',
            filters: {
                max_file_size: '10mb',
                mime_types: [
                    {title: "Image files", extensions: "jpg,gif,png"}
                ],
                prevent_duplicates: false
            },
            multi_selection: true,
            unique_names: true,

            flash_swf_url: '{{ url('vendor/plupload-2.1.2/Moxie.swf') }}',
            silverlight_xap_url: '{{ url('vendor/plupload-2.1.2/Moxie.xap') }}',

            file_data_name: 'photo',
            headers: {
                Accept: 'application/json'
            },

            multipart_params: {
                _token: '{{ csrf_token() }}'
            },

            init: {
                PostInit: function () {
                },

                FilesAdded: function (up, files) {
                    up.start();
                },

                BeforeUpload: function (up, file) {
                    up.settings.multipart_params.file_name = file.name;
                },

                UploadProgress: function (up, file) {
                    $('.msg').html('上传中...');
                },

                Error: function (up, err) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(err.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    noty({
                        type: 'error',
                        text: err.message + ' ' + responseMessage,
                        callback: {
                            afterClose: function () {
                                $('#inputImage').show();
                                $('#inputImageProgress').hide();
                            }
                        }
                    });
                },

                FileUploaded: function (up, file, info) {
                    var responseObj = '', responseMessage = '';
                    try {
                        responseObj = $.parseJSON(info.response);
                        responseMessage = responseObj.message;
                    } catch ($e) {

                    }

                    var $inputImage = $('.msg');
                    $inputImage.html('上传成功！');
                    $inputImage.show();

                    var imageUrl = '', imageId = 0;
                    if (responseObj && responseObj.data) {
                        var d = new Date();
                        imageUrl = "{{route('Api.Images.Show')}}?"+d.getTime();
                        imageId = responseObj.data.id;
                    }
                    $('#project_logo_url').attr('src', imageUrl);
                    if(imageId !== null){
                        $('#photo_id').val(imageId);
                    }else{
                        $('#photo_id').val('0');
                    }
                }
            }
        });
        uploader.init();
    </script>
    
    @endsection


